package com.ip.getip.util;

import javax.servlet.http.HttpServletRequest;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @ Description   :
 * @ Author        :  leixin
 * @ CreateDate    :  2021/12/2-10:12
 * @ Version       :  1.0
 */
public class TokenUtils {

    public static String getToken(){
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
        if(StringUtils.isEmpty(request.getHeader("Authorization"))){
            return null;
        }
        return request.getHeader("Authorization");
    }
}
